<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>水平居中布局解决方案3-text-align+inline-block</title>
  <style>
    * {
      margin: 0;
      padding: 0;
    }
    /* 多个块居中 text-align+inline-block */
    #parent{
       width: 500px;
       height: 500px;
       background-color: red;
       text-align: center;
     }
     .child{
       display: inline-block;
       width: 20px;
       height: 20px;
       border-radius: 50%;
       background-color: blue;
       margin:10px;
     }

  </style>
</head>

<body>
  <!-- 定义父级元素 后台 2 居中  3  居中  ... -->
  <div id="parent">
    <!-- 定义子级元素 -->
    <div class="child">1</div>
    <div class="child">2</div>
    <div class="child">3</div>
  </div>
</body>

</html>